<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 流年 <liu21st@gmail.com>
// +----------------------------------------------------------------------

// 应用公共文件
error_reporting(E_ALL ^ E_NOTICE);

/**
 * 返回格式化的时间
 * @param bool $only_date
 * @return false|string
 */
function now($only_date = FALSE) {
  return $only_date ? date('Y-m-d') : date("Y-m-d H:i:s");
}

function cmf_sidebar_menu() {
  $model = new \app\base\model\Menu();

  return $model->sidebarMenu();
}

function cmf_user_info($uid) {
  $model = new \app\base\model\User();

  return $model->cache(86400)->find($uid);
}

function cmf_user_realname($uid) {
  return cmf_user_info($uid)['realname'];

}


function cmf_get_commitment() {
  $model = new \app\admin\model\Commitment();

  return $model->order('id DESC')->find();
}

function cmf_log($content, $dataid = 0, $extra = '', $uid = NULL) {
  $model = new \app\base\model\Log();
  $model->add($content, $dataid, $extra, $uid = ($uid ? $uid : session('user_id')));
}